<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>乐优商城--支付页-成功</title>
    <link rel="icon" href="/assets/img/favicon.ico">
    <link rel="stylesheet" type="text/css" href="css/webbase.css"/>
    <link rel="stylesheet" type="text/css" href="css/pages-paysuccess.css"/>
</head>
<body>
<!--head-->
<div id="paySvm">
    <div class="top">
        <shortcut/>
    </div>
    <div class="cart py-container">
        <!--logoArea-->
        <div class="logoArea">
            <div class="fl logo"><span class="title">支付页</span></div>
        </div>
        <!--主内容-->
        <div class="paysuccess">
            <div class="success" v-if="!errorState">
                <h3><img src="img/_/right.png" width="48" height="48">　恭喜您，支付成功啦！</h3>
                <div class="paydetail">
                    <p>支付方式：微信支付</p>
                    <p>支付金额：￥{{ly.formatPrice(totalPay)}}元</p>
                    <p class="button">
                        <a href="home-index.html" class="sui-btn btn-xlarge btn-danger">查看订单</a>&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="index.html" class="sui-btn btn-xlarge ">继续购物</a>
                    </p>
                </div>
            </div>
            <div class="success" v-if="errorState">
                <h3 style="color:red;">订单不存在或订单未支付！</h3>
                <p class="button">
                    <a href="home-index.html" class="sui-btn btn-xlarge btn-danger">查看订单</a>&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="index.html" class="sui-btn btn-xlarge ">继续购物</a>
                </p>
            </div>

        </div>
    </div>
</div>
<script src="./js/vue/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/common.js"></script>
<script type="text/javascript">
    var payVm = new Vue({
        el: "#paySvm",
        data: {
            ly,
            orderId: 0, //订单id
            totalPay: 0, //实际支付总金额
            errorState: false
        },
        created() {
            this.orderId = leyou.getUrlParam("orderId");
            ly.verifyUser().then(() => {
                ly.store.del("selectedCarts");

                if (this.orderId === "") {
                    this.errorState = true;
                }

                ly.http.get("/order/" + this.orderId).then(resp => {
                    debugger
                    if (resp.status === 200) {
                        if (resp.data.status === 1) {
                            this.errorState = true;
                        } else {
                            this.totalPay = resp.data.actualPay;
                        }
                    } else {
                        location.href = "/home-index.html";
                    }
                }).catch(() => {
                    //跳转到我我的订单页
                    location.href = "/home-index.html";
                });
            }).catch(() => {
                location.href = "/login.html?returnUrl=" + location.href;
            });
        },
        components: {
            shortcut: () => import("/js/pages/shortcut.js")
        },
    });
</script>

<!-- 底部栏位 -->
<!--页面底部，由js动态加载-->
<script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
<div class="clearfix footer"></div>
<script type="text/javascript">$(".footer").load("foot.html");</script>
<!--页面底部END-->


<script type="text/javascript" src="js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="components/ui-modules/nav/nav-portal-top.js"></script>
</body>
</html>